package czk.jvm.lecture.alibaba;

import czk.jvm.lecture.classloader.MyPerson;

import java.util.Objects;

public class ObjectsDemo {
    public static void main(String[] args) {
        /**
         * Objects.equals(n1,n2)
         * alibaba推荐使用
         * 避免了空指针异常的抛出
         */
        MyPerson myPerson=new MyPerson();
        String str=null;
        //报错、空指针异常
        boolean equals1 = str.equals(myPerson);
        System.out.println(equals1);
        //不会报错
        boolean equals = Objects.equals(str, myPerson);
        System.out.println(equals);
        Animal animal=new Animal();

    }
}
